|
In computer science and discrete mathematics, an inversion is a pair of places of a sequence where the elements on these places are out of their natural order. == Definitions == Formally, let be a sequence of ''n'' distinct numbers. If and , then the pair is called an inversion of . The inversion number of a sequence is one common measure of its sortedness. Formally, the inversion number is defined to be the number of inversions, that is, :. Equivalently, it is the Kendall tau distance from the identity permutation. Other measures of (pre-)sortedness include the minimum number of elements that can be deleted from the sequence to yield a fully sorted sequence, the number and lengths of sorted "runs" within the sequence, the Spearman footrule (sum of distances of each element from its sorted position), and the smallest number of exchanges needed to sort the sequence. Standard comparison sorting algorithms can be adapted to compute the inversion number in time . The inversion vector ''V(i)'' of the sequence is defined for ''i'' = 2, ..., ''n'' as . In other words each element is the number of elements preceding the element in the original sequence that are greater than it. Note that the inversion vector of a sequence has one less element than the sequence, because of course the number of preceding elements that are greater than the first is always zero. Each permutation of a sequence has a unique inversion vector and it is possible to construct any given permutation of a (fully sorted) sequence from that sequence and the permutation's inversion vector. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Inversion (discrete mathematics)」の詳細全文を読む スポンサード リンク
|